﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using GameEngine;
using Tomers.WPF.Localization;

namespace Daphne.Controls
{
    /// <summary>
    /// Interaction logic for GameStatus.xaml
    /// </summary>
    public partial class GameStatus : UserControl
    {
        public GameStatus()
        {
            InitializeComponent();
        }

        public void UpdateStatus(eGameType gameType, enumGameResult gameResult, int computerLevel)
        {
            UpdateGameType(gameType);
            UpdateGameResult(gameResult);
            UpdateComputerLevel(computerLevel);
        }

        public void UpdateGameType(eGameType gameType)
        {
            switch (gameType)
            {
                case eGameType.OnePlayer:
                    uxGameType.Content = GetTextValue("CTR_OnePlayerGame");
                    break;
                case eGameType.TwoPlayer:
                    uxGameType.Content = GetTextValue("CTR_TwoPlayerGame");
                    break;
                case eGameType.EngineMatch:
                    uxGameType.Content = GetTextValue("CTR_ComputerMatch");
                    break;
            }
        }

        public void UpdateGameResult(enumGameResult gameResult)
        {
            switch (gameResult)
            {
                case enumGameResult.WhiteWin:
                    uxGameResult.Content = GetTextValue("CTR_WhiteWin");
                    break;
                case enumGameResult.BlackWin:
                    uxGameResult.Content = GetTextValue("CTR_BlackWin");
                    break;
                case enumGameResult.Draw:
                    uxGameResult.Content = GetTextValue("CTR_Draw");
                    break;
                default:
                    uxGameResult.Content = "????";
                    break;
            }
        }

        public void UpdateComputerLevel(int computerLevel)
        {
            uxComputerLevel.Content = computerLevel.ToString();
        }

        private static string GetTextValue(string sKey)
        {
            const string keyValue = "Value";
            return LanguageContext.Instance.Dictionary.Translate<string>(sKey, keyValue);

        }
    }
}
